package com.zhuiyun.pm.client.bidding.controller;

import com.zhuiyun.pm.client.bidding.entity.ClientGoodsInfo;
import com.zhuiyun.pm.client.bidding.mapper.ClientGoodsInfoMapper;
import com.zhuiyun.pm.client.bidding.service.ClientGoodsInfoService;
import com.zhuiyun.pm.result.CommonResult;
import org.springframework.web.bind.annotation.*;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/listBysellerId")
public class ClientGoodsInfoController {
    @Resource
    ClientGoodsInfoMapper clientGoodsInfoMapper;
    @Resource
    ClientGoodsInfoService clientGoodsInfoService;
    /* *
     * @Author: hui
     * @Descriprion: 全查
     * @Date: 2023/3/13 13:42
     * @return com.zhuiyun.pm.result.CommonResult
     */
    @GetMapping("/findAll")
    public CommonResult findAll(){
        return CommonResult.ok(clientGoodsInfoMapper.selectAll());
    }
    /* *
     * @Author: hui
     * @Descriprion: 根据status查询状态
     * @Date: 2023/3/13 14:39
     * @return com.zhuiyun.pm.result.CommonResult
     * @param status
     */
    @GetMapping("/finAllBystatus")
    public CommonResult finAllBystatus(@RequestParam Integer checkStatus){
        Example example = new Example(ClientGoodsInfo.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("checkStatus",checkStatus);
        List list = clientGoodsInfoMapper.selectByExample(example);
        return CommonResult.ok(list);
    }
    /* *
     * @Author: hui
     * @Descriprion: 根据Id单查数据
     * @Date: 2023/3/13 15:23
     * @return com.zhuiyun.pm.result.CommonResult
     * @param id
     */
    @GetMapping("/finAllById")
    public CommonResult finAllById(@RequestParam Integer id){
        return CommonResult.ok(clientGoodsInfoMapper.selectByPrimaryKey(id));
    }
    /* *
     * @Author: hui
     * @Descriprion: 根据卖家查询我的拍卖
     * @Date: 2023/3/14 19:00
     * @return com.zhuiyun.pm.result.CommonResult
     * @param userid
     */
    /**
     * @Author 小江
     * @Description //TODO 买拍全查
     * @Date 14:09 2023/3/17
     **/
    @GetMapping("/listBysellerId")
    public CommonResult listByUserId(@RequestParam Integer sellerId ,@RequestParam(defaultValue = "") String goodsName){
//        Example example = new Example(ClientGoodsInfo.class);
//        Example.Criteria criteria = example.createCriteria();
//        criteria.andEqualTo("sellerId",sellerId);
//        List list = clientGoodsInfoMapper.selectByExample(example);
        return CommonResult.ok(clientGoodsInfoMapper.findAll(sellerId,goodsName));
    }
}
